package com.jiazhong.basic.shuxin.net;

import lombok.SneakyThrows;

import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;

public class DemoB {

    @SneakyThrows
    public static void main(String[] args) {
        URL url = new URL("https://www.bjwlxy.cn/");
        URLConnection urlConnection = url.openConnection();
        HttpURLConnection httpURLConnection = (HttpURLConnection) urlConnection;
        InputStream inputStream = httpURLConnection.getInputStream();
        byte[] bytes = new byte[1024];
        int len;
        while ((len = inputStream.read(bytes)) != -1) {
            System.out.print(new String(bytes, 0, len));
        }
        inputStream.close();
        httpURLConnection.disconnect();
    }
}
